package org.njo.webapp.templates.config;

import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSetBase;

public class ConfigRuleSet extends RuleSetBase {

    /**
     * <p>Add the set of Rule instances defined in this RuleSet to the
     * specified <code>Digester</code> instance, associating them with
     * our namespace URI (if any).  This method should only be called
     * by a Digester instance. </p>
     *
     * @param digester Digester instance to which the new Rule instances
     *  should be added.
     */
    public void addRuleInstances(Digester digester) {

        // 
        digester.addObjectCreate(
                "templates-config",
                "org.njo.webapp.templates.config.TemplatesConfig");
        //
        digester.addSetProperties("templates-config");
        
        
        
        // 
        digester.addObjectCreate(
                "templates-config/pattern",
                "org.njo.webapp.templates.config.PatternConfig");
        digester.addSetProperties("templates-config/pattern");
        //
        digester.addObjectCreate(
                "templates-config/pattern/template",
                "org.njo.webapp.templates.config.TemplateConfig");
        //
        digester.addSetProperties("templates-config/pattern/template");
        
        digester.addObjectCreate(
                "templates-config/pattern/template/param",
                "org.njo.webapp.templates.config.ParamConfig");
        digester.addSetProperties("templates-config/pattern/template/param");
        
        
        
        // 
        digester.addSetNext(
                "templates-config/pattern/template/param",
                "addParamConfig",
                "org.njo.webapp.templates.config.ParamConfig");
        //
        digester.addSetNext(
                "templates-config/pattern/template",
                "addTemplateConfig",
                "org.njo.webapp.templates.config.TemplateConfig");
        
        //
        digester.addSetNext(
                "templates-config/pattern",
                "addPatternConfig",
                "org.njo.webapp.templates.config.PatternConfig");

        // 
        digester.addObjectCreate(
                "templates-config/formatter",
                "org.njo.webapp.templates.config.FormatterConfig");
        digester.addSetProperties("templates-config/formatter");
        // 
        digester.addObjectCreate(
                "templates-config/formatter/param",
                "org.njo.webapp.templates.config.ParamConfig");
        digester.addSetProperties("templates-config/formatter/param");
        // 
        digester.addSetNext(
                "templates-config/formatter/param",
                "addParamConfig",
                "org.njo.webapp.templates.config.ParamConfig");
        //
        digester.addSetNext(
                "templates-config/formatter",
                "addFormatterConfig",
                "org.njo.webapp.templates.config.FormatterConfig");
        
    }
    
    

}
